﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataAccess;
using System.Data;

namespace EntityDaoLibrary
{
    public class ChargeItemInfoDAO : IEntityDAO
    {
        private IDataAccess data;
        public ChargeItemInfoDAO()
        {
 
        }
        public ChargeItemInfoDAO(IDataAccess data)
        {
            this.data = data;
        }

        #region IEntityDAO 成员

        public void insertEntity(System.Data.DataSet entityData)
        {
            throw new NotImplementedException();
        }

        public void deleteEntity(System.Data.DataSet entityData)
        {
            throw new NotImplementedException();
        }

        public void updateEntity(System.Data.DataSet entityData)
        {
            throw new NotImplementedException();
        }

        public System.Data.DataSet FindByPrimaryKey(object strKeyValue)
        {
            throw new NotImplementedException();
        }

        #endregion


        /// <summary>
        /// 根据住院号查询病人费用明细
        /// </summary>
        /// <param name="syxh"></param>
        public DataSet GetChargeInfoByInhosID(string inhosid)
        {
            try
            {
                QueryParameterCollection para;
                DataSet ds = new DataSet();
//                string sql = @"SELECT ZY_BRFYMXK.* ,ZY_BRSYK.hzxm FROM ZY_BRFYMXK,ZY_BRSYK 
//                                WHERE ZY_BRFYMXK.syxh=ZY_BRSYK.syxh AND ZY_BRSYK.blh=@blh
//                            ";

                string sql = @"SELECT * FROM ZY_BRFYMXK A,
                                (SELECT ZY_BRSYK.hzxm,ZY_BRSYK.syxh,ZY_BRSYK.blh,I_RALATIONINHOSREG.MEDICARENO FROM ZY_BRSYK,I_RALATIONINHOSREG WHERE ZY_BRSYK.blh=I_RALATIONINHOSREG.INHOSID AND I_RALATIONINHOSREG.INHOSID=@MEDICARENO
                                ) AS B WHERE A.syxh=B.syxh AND A.jlzt=0 ORDER BY A.ypmc,ypsl  ";
                para = new QueryParameterCollection(1);
                para.Add("@MEDICARENO", inhosid);
                data.ExecuteDataset(sql, para, ds,"INHOSCHARGEINFO");
                return ds;
            }
            catch (Exception e)
            {

                throw new Exception(e.Message, e);
            }
            
        }


        public int UpdateMedicareInfo(string inhosid, string medicareInfo)
        {
            return 0;
        }



    }
}
